if(typeof AnalyzeStatus == "undefined"){
    var AnalyzeStatus = {
        NotRun:0,
        Playing:1,
        Started:2,
        Stoped:3,
        ReleaseRoom:4,
        OnError:5
    };
}

class AIAnalyzeData {
    constructor() {
        this.cameraId = "";
        this.cameraIP = "";
        this.uri = "";
        this.extends = "";
        this.type = "";
        this.remark ="";
        this.fps = 25;
        this.height = 1080;
        this.width = 1920;
        this.maxBitRate = 12000000;

        this.status = AnalyzeStatus.NotRun;
        this.startError = false;
        this.startErrorMessage = "";

        this.streamId = "";
    }
    onStart(ret){
        if (null == ret || !ret[0] || ret.length < 2) {
            this.startStatus = false;
            if (ret.length > 1) {
                this.startError = true;
                this.startErrorMessage = ret[1];
            }
        } else {
            this.startStatus = ret[0];
            this.startError = false;
        }
    }
    getPlayParam(_token, _appkey) {
        return {
                appkey:_appkey,
                room:this.cameraId,
                options:{
                uri:this.uri,
                    params:{
                    audio:false,
                        video:true,
                        loop:1,
                        bitrate:this.maxBitRate,
                        custom_token:_token
                }
            }
        };
    }
    getStartAnalyzeParam(_appkey) {
        return {
            appkey:_appkey,
            room:this.cameraId,
            stream:this.streamId,
            options:{
                type:this.type,
                width:this.width,
                height:this.height,
                params:{
                    type:this.type,
                    fps:this.fps,
                    extends:{
                        cameraId:this.cameraId,
                        extends: this.extends,
                        ip:this.cameraIP
                    }
                }
            }
        };
    }

    getStopAnalyzeParam(_appkey) {
        return {
            appkey:_appkey,
            room:this.cameraId,
            stream:this.streamId,
            options:{
                type:this.type
            }
        };
    }

    getReleaseParam(_token, _appkey) {
        return {
            appkey:_appkey,
            room:this.cameraId,
            custom_token:_token
        };
    }
}

module.exports = {AIAnalyzeData, AnalyzeStatus};
